{extend name="public/base"/}
{block name="body"}
<title>留言列表</title>
<style type="text/css">
	.pagelist ul li{display:inline-block;width:20px;height:20px;text-align:center;}
	.pagelist ul li a{width:20px;height:20px;}
	.pagelist ul li.active{background-color:#ccc !important;color:#fff;}
	.select_state{width:80px;height:30px;border:solid 1px #ddd;}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 联系我们 <span class="c-gray en">&gt;</span> 留言列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="text-c">
		状态： 
		<select id="select_state" class="select_state" name="state" size="1">
				<option value="0" {if $state==0}selected{/if}>全部</option>
				<option value="1" {if $state==1}selected{/if}>待处理</option>
				<option value="2" {if $state==2}selected{/if}>处理中</option>
				<option value="2" {if $state==3}selected{/if}>已处理</option>
		</select>
		日期范围：
		
		<input name="fromtime" type="text" {literal} onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" {/literal} id="datemin" class="input-text Wdate" style="width:120px;" value="{$fromtime}">
		-
		<input name="totime" type="text" {literal} onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" {/literal} id="datemax" class="input-text Wdate" style="width:120px;" value="{$totime}">
		
		<input type="text" class="input-text" style="width:250px" placeholder="输入姓名/电话/邮箱/公司" id="keyword" name="keyword" value="{$keyword}">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
	</div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="11">留言列表<span class="r">共有数据：<strong>{$lists}</strong> 条</span></th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="60">姓名</th>
				<th width="100">电话</th>
				<th width="100">邮箱</th>
				<th width="120">公司</th>
				<th width="100">IP</th>
				<th width="150">留言</th>
				<th width="50">处理状态</th>
				<th width="130">时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach $list as $key=>$value }
			<tr class="text-c" id="val_{$value.id}">
				<td>{$value.id}</td>
				<td>{$value.name}</td>
				<td>{$value.tel}</td>
				<td>{$value.email}</td>
				<td>{$value.company}</td>
				<td>{$value.ip}</td>
				<td  title="{$value.message}"><p style="width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:auto;">{$value.message}</p></td>
				<td class="td-status">
					{if $value.state==1}
						待处理
					{elseif $value.state==2}
						处理中
					{elseif $value.state==3}
						已处理
					{/if}
				</td>
				<td>{:date('Y-m-d H:i:s',$value.time)}</td>
				<td class="td-manage" id="state_nf{$value.id}">
					{if $value.state==1}
						<span class="label label-success radius" style="cursor:pointer;" onClick="state_ing({$value.id});">受理</span>
					{elseif $value.state==2}
						<span class="label label-primary radius" style="cursor:pointer;" onClick="state_ed({$value.id});">完毕</span>
					{/if}
				</td>
			</tr>
      		{/foreach}
		    <tr>
		        <td colspan="12">
			        <div class="pagelist"  style="text-align: right;">
			        	{$list->render()|raw}
			        </div>
		        </td>
		    </tr>
		</tbody>
	</table>
</div>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
/*停用*/
function state_ing(id){
	$.post('{:url("state_ing")}',
    {id:id},
    function(data){
        if(data.code==200){
            window.location.reload()
        }
    });
    return false;
}
/*启用*/
function state_ed(id){
	$.post('{:url("state_ed")}',
    {id:id},
    function(data){
        if(data.code==200){
            layer.msg(data.msg,{icon:1,time:1000});
        	setTimeout("window.location.reload()",1000);
        }
    });
    return false;
}

$(".pagelist").on("click",".pagination a",function(){
  var url=$(this).attr("href");
  var fromtime=$("#datemin").val();
  var totime=$("input[name=totime]").val();
  var keyword=$("#keyword").val();
  var state=$("#select_state").val();
  url=url+'&fromtime='+fromtime+'&totime='+totime+'&keyword='+keyword+'&state='+state;
  getPage(url);
  return false;
});
function getPage(url)
{
  $.get(url, function(data){
    $("body").html(data);

  });
}
</script>
{/block}